//
//  StoryTableViewCell.m
//  Travelmemory
//
//  Created by lanou3g on 16/3/24.
//  Copyright © 2016年 ABCD. All rights reserved.
//

#import "StoryTableViewCell.h"

@interface StoryTableViewCell()

@property (nonatomic, strong) UICollectionViewFlowLayout *layout;

@end

@implementation StoryTableViewCell

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        // 布局collectionView
        [self createCollectionView];
        
    }
    return self;
}

#pragma mark - collectionView
- (void)createCollectionView {
    
    self.layout = [[UICollectionViewFlowLayout alloc] init];
    self.layout.sectionInset = UIEdgeInsetsMake(0, 0, 0, 0);
    self.layout.itemSize = CGSizeMake(100, 100);
    self.layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
    self.collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:self.layout];
    
    self.collectionView.backgroundColor = [UIColor whiteColor];
    [self.contentView addSubview:self.collectionView];
    self.collectionView.showsHorizontalScrollIndicator = NO;
}

- (void)layoutSubviews {
    [super layoutSubviews];
    
    self.collectionView.frame = self.contentView.bounds;
    self.layout.sectionInset = UIEdgeInsetsMake(0, 5, 0, 0);
    self.layout.minimumInteritemSpacing = 0;
    self.layout.itemSize = CGSizeMake(self.contentView.frame.size.width / 2 - 30, self.contentView.frame.size.height);
}


@end
